import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class TextInputWidget extends StatelessWidget {
  final TextEditingController controller;
  final Widget suffixWidget;
  final String title;
  final String hintText;
  final bool enable;

  const TextInputWidget({
    Key key,
    this.controller,
    this.suffixWidget,
    this.title,
    this.hintText,
    this.enable = true,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: 20.w),
      child: Container(
        padding: EdgeInsets.symmetric(
          vertical: 32.w,
        ),
        decoration: BoxDecoration(
          border: Border(
            bottom: BorderSide(
              color: Color(0xfff0f0f0),
            ),
          ),
        ),
        child: Row(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.spaceBetween,
          children: [
            Container(
              width: 280.w,
              child: Text(
                title,
                style: TextStyle(
                  color: Color(0xff666666),
                  fontSize: 28.sp,
                ),
              ),
            ),
            Container(
              width: 350.w,
              child: controller != null
                  ? TextField(
                      controller: controller,
                      enabled: enable,
                      textAlignVertical: TextAlignVertical.center,
                      textAlign: TextAlign.end,
                      decoration: InputDecoration(
                        isDense: true,
                        contentPadding: EdgeInsets.all(0),
                        hintText: hintText,
                        hintStyle: TextStyle(
                          fontSize: 28.sp,
                          color: Color(0xffcccccc),
                        ),
                        border: InputBorder.none,
                      ),
                    )
                  : suffixWidget,
            ),
          ],
        ),
      ),
    );
  }
}
